package com.kuki996.service;

import java.util.*;

public class Poker {
    //牌组
    private static List<Integer> list = new ArrayList<>();
    private static HashMap<Integer, String> map = new HashMap<>();

    public void pokerGame() {
        //准备牌
        String[] color = {"♣", "♠", "♦", "♥"};
        String[] number = {"3", "4", "5", "6", "7", "8", "9", "10", "J", "Q", "K", "A", "2"};
        //创建牌盒
        Integer tmp = 1;
        for (String c : number) {
            for (String n : color) {
                map.put(tmp, n + c);
                list.add(tmp);
                tmp++;
            }
        }
        map.put(tmp, "小王");
        list.add(tmp);
        tmp++;
        map.put(tmp, "大王");
        list.add(tmp);
        //洗牌
        Collections.shuffle(list);
        // System.out.println(list);
        //发牌
        TreeSet<Integer> lord = new TreeSet<>();
        TreeSet<Integer> player1 = new TreeSet<>();
        TreeSet<Integer> player2 = new TreeSet<>();
        TreeSet<Integer> player3 = new TreeSet<>();
        for (int i = 0; i < list.size(); i++) {
            Integer poker = list.get(i);
            if (i <= 2) {
                lord.add(poker);
                continue;
            }
            if (i % 3 == 0) {
                player1.add(poker);
            } else if (i % 3 == 1) {
                player2.add(poker);
            } else {
                player3.add(poker);
            }

        }
        LookPoker("底牌", lord);
        LookPoker("熊大", player1);
        LookPoker("熊二", player2);
        LookPoker("熊三", player3);

    }

    //看牌
    public void LookPoker(String name, TreeSet<Integer> list) {
        List<String> myPoker = new ArrayList<>();
        for (Integer l : list) {
            String poker = map.get(l);
            myPoker.add(poker);
        }
        System.out.println(name+":"+myPoker);
    }
}
